package cn.snmp.mutual.uk.stack;

import java.io.*;

class AsnTrapPduv1Sequence extends AsnSequence {
    private static final String version_id = "@(#)$Id: AsnTrapPduv1Sequence.java,v 3.6 2006/01/17 17:43:54 birgit Exp $ Copyright Westhawk Ltd";

    AsnTrapPduv1Sequence(final InputStream in, final int len, final int pos) throws IOException {
        super(in, len, pos);
    }

    String getEnterprise() throws DecodingException {
        String ent = "";
        final AsnObject obj = this.getObj(0);
        if (obj instanceof AsnObjectId) {
            final AsnObjectId rid = (AsnObjectId) obj;
            ent = rid.getValue();
            return ent;
        }
        final String msg = "TrapPduv1.Enterprise should be AsnObjectId instead of " + obj.getRespTypeString();
        throw new DecodingException(msg);
    }

    byte[] getIPAddress() throws DecodingException {
        byte[] ip = null;
        final AsnObject obj = this.getObj(1);
        if (obj instanceof AsnOctets) {
            final AsnOctets estat = (AsnOctets) obj;
            ip = estat.getBytes();
            return ip;
        }
        final String msg = "TrapPduv1.IPAddress should be of type AsnOctets instead of " + obj.getRespTypeString();
        throw new DecodingException(msg);
    }

    int getGenericTrap() throws DecodingException {
        int genTrap = -1;
        final AsnObject obj = this.getObj(2);
        if (obj instanceof AsnInteger) {
            final AsnInteger estat = (AsnInteger) obj;
            genTrap = estat.getValue();
            return genTrap;
        }
        final String msg = "TrapPduv1.GenericTrap should be of type AsnInteger instead of " + obj.getRespTypeString();
        throw new DecodingException(msg);
    }

    int getSpecificTrap() throws DecodingException {
        int specTrap = -1;
        final AsnObject obj = this.getObj(3);
        if (obj instanceof AsnInteger) {
            final AsnInteger estat = (AsnInteger) obj;
            specTrap = estat.getValue();
            return specTrap;
        }
        final String msg = "TrapPduv1.SpecificTrap should be of type AsnInteger instead of " + obj.getRespTypeString();
        throw new DecodingException(msg);
    }

    long getTimeTicks() throws DecodingException {
        long ticks = -1L;
        final AsnObject obj = this.getObj(4);
        if (obj instanceof AsnUnsInteger) {
            final AsnUnsInteger estat = (AsnUnsInteger) obj;
            ticks = estat.getValue();
            return ticks;
        }
        final String msg = "TrapPduv1.TimeTicks should be of type AsnUnsInteger instead of " + obj.getRespTypeString();
        throw new DecodingException(msg);
    }

    AsnSequence getVarBind() throws DecodingException {
        AsnSequence varb = null;
        final AsnObject obj = this.getObj(5);
        if (obj instanceof AsnSequence) {
            varb = (AsnSequence) obj;
            return varb;
        }
        final String msg = "TrapPduv1.VarBind should be of type AsnSequence instead of " + obj.getRespTypeString();
        throw new DecodingException(msg);
    }

    @Override
    AsnObject findTrapPduv1() {
        return this;
    }
}
